
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
null</title>
<script type="text/javascript" src="http://api.map.baidu.com/api?key=67f19b2653d068ffd5fd2bf6ddd1149d&v=1.2&services=true">
</script>
</head>
<body>
<input type="hidden" id="first">
<input type="hidden" id="last">
<input type="hidden" id="title0">
<input type="hidden" id="title1">
<input type="hidden" id="title2">
<input type="hidden" id="title3">
<input type="hidden" id="title4">
<input type="hidden" id="title5">
<input type="hidden" id="title6">
<input type="hidden" id="title7">
<input type="hidden" id="title8">
<input type="hidden" id="title9">
<input type="hidden" id="addr0">
<input type="hidden" id="addr1">
<input type="hidden" id="addr2">
<input type="hidden" id="addr3">
<input type="hidden" id="addr4">
<input type="hidden" id="addr5">
<input type="hidden" id="addr6">
<input type="hidden" id="addr7">
<input type="hidden" id="addr8">
<input type="hidden" id="addr9">
<input type="hidden" id="poi0">
<input type="hidden" id="poi1">
<input type="hidden" id="poi2">
<input type="hidden" id="poi3">
<input type="hidden" id="poi4">
<input type="hidden" id="poi5">
<input type="hidden" id="poi6">
<input type="hidden" id="poi7">
<input type="hidden" id="poi8">
<input type="hidden" id="poi9">
<div style="width:100%;height:100%;" id="container">
</div>
<div id="log" style="font-size:13px;margin-top:0px;display:none;">
</div>
</body>
</html>
<script type="text/javascript">

//form.submit();

var city = window.qml.city;
var map = new BMap.Map("container");
map.setCurrentCity(city);
map.centerAndZoom(city);

//map.centerAndZoom(new BMap.Point(113.32, 23.15), 13);
//map.centerAndZoom("广州市");
//map.setCurrentCity("广州市");
//var opts = {type: BMAP_NAVIGATION_CONTROL_ZOOM, offset: new BMap.Size(50, 50)}
//map.addControl(new BMap.NavigationControl(opts));

//window.qml.qmlCall();

//var marker = new BMap.Marker();

var myGeo = new BMap.Geocoder();

var options0 = { 
  renderOptions: {map: map,autoViewport: true},
  onSearchComplete: function(results){
    if (transit.getStatus() == BMAP_STATUS_SUCCESS){
      // 获取第一条方案
      alert("fuok fuok fuok");
      var plan = results.getPlan(0);

      //for (i = 0; i < plan.getNumLines(); i ++){
	//  var line = plan.getLine(i);
	//  map.addOverlay(new BMap.Polyline(line.getPoints()));
      //}

      // 获取方案的公交线路
    var s = [];
    for (i = 0; i < results.getNumPlans(); i ++){
      s.push((i + 1) + ". " + results.getPlan(i).getDescription());
    }
    //alert(s);
    document.getElementById("log").innerHTML = s.join("<br/>");
    window.qml.searchsuccess();
    //document.getElementById("log").innerHTML = results.toString() ;
    window.qml.route = document.getElementById("log").innerHTML;
    window.qml.showroute();
    }
  }
};
var transit = new BMap.TransitRoute(map,options0);
//var transit = new BMap.TransitRoute(map);



var firstt = document.getElementById("first").value 
var lastt = document.getElementById("last").value
//transit.search("五山", "体育中心");
//alert(firstt);
//transit.search(firstt, lastt);


var options1 = { 
  renderOptions: {map: map,autoViewport: true},
  onSearchComplete: function(results){
    if (driving.getStatus() == BMAP_STATUS_SUCCESS){
      // 获取第一条方案
      var plan = results.getPlan(0);

      //for (i = 0; i < plan.getNumLines(); i ++){
	//  var line = plan.getLine(i);
	//  map.addOverlay(new BMap.Polyline(line.getPoints()));
      //}

      // 获取方案的驾车线路
      var route = plan.getRoute(0);

      // 获取每个关键步骤,并输出到页面
      var s = [];
      for (var i = 0; i < route.getNumSteps(); i ++){
        var step = route.getStep(i);
        s.push((i + 1) + ". " + step.getDescription());
      }
      document.getElementById("log").innerHTML = s.join("<br/>");
      window.qml.searchsuccess();
///////////////////////////////
      window.qml.route = document.getElementById("log").innerHTML;
      window.qml.showroute();
    }
  }
};
var driving = new BMap.DrivingRoute(map, options1);



var options = {
  onSearchComplete: function(results){
    if (local.getStatus() == BMAP_STATUS_SUCCESS){
      // 判断状态是否正确
      //var s = [];
      for (var i = 0; i < results.getCurrentNumPois(); i ++){
	//document.getElementById("addr" + i).value = (results.getPoi(i).title + ", " + results.getPoi(i).address);
	document.getElementById("addr" + i).value = (results.getPoi(i).address);
	document.getElementById("title" + i).value = (results.getPoi(i).title);
	document.getElementById("poi" + i).value = (results.getPoi(i).point.lng + "," + results.getPoi(i).point.lat);
	//window.qml.addr.push(results.getPoi(i).title + ", " + results.getPoi(i).address);
        //s.push(results.getPoi(i).title + ", " + results.getPoi(i).address);
      }
      //document.getElementById("log").innerHTML = s.join("<br/>");

      window.qml.title0 = document.getElementById("title0").value;
      window.qml.title1 = document.getElementById("title1").value;
      window.qml.title2 = document.getElementById("title2").value;
      window.qml.title3 = document.getElementById("title3").value;
      window.qml.title4 = document.getElementById("title4").value;
      window.qml.title5 = document.getElementById("title5").value;
      window.qml.title6 = document.getElementById("title6").value;
      window.qml.title7 = document.getElementById("title7").value;
      window.qml.title8 = document.getElementById("title8").value;
      window.qml.title9 = document.getElementById("title9").value;

      window.qml.addr0 = document.getElementById("addr0").value;
      window.qml.addr1 = document.getElementById("addr1").value;
      window.qml.addr2 = document.getElementById("addr2").value;
      window.qml.addr3 = document.getElementById("addr3").value;
      window.qml.addr4 = document.getElementById("addr4").value;
      window.qml.addr5 = document.getElementById("addr5").value;
      window.qml.addr6 = document.getElementById("addr6").value;
      window.qml.addr7 = document.getElementById("addr7").value;
      window.qml.addr8 = document.getElementById("addr8").value;
      window.qml.addr9 = document.getElementById("addr9").value;

      window.qml.poi0 = document.getElementById("poi0").value;
      window.qml.poi1 = document.getElementById("poi1").value;
      window.qml.poi2 = document.getElementById("poi2").value;
      window.qml.poi3 = document.getElementById("poi3").value;
      window.qml.poi4 = document.getElementById("poi4").value;
      window.qml.poi5 = document.getElementById("poi5").value;
      window.qml.poi6 = document.getElementById("poi6").value;
      window.qml.poi7 = document.getElementById("poi7").value;
      window.qml.poi8 = document.getElementById("poi8").value;
      window.qml.poi9 = document.getElementById("poi9").value;

      window.qml.qmlCall();

    }
  }
};
var local = new BMap.LocalSearch(map, options);
//local.search("五山");

</script>

